package sg.edu.nus.iss.billing.gui;

//Tan Pic Cheng

import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import sg.edu.nus.iss.billing.entity.Customer;
import sg.edu.nus.iss.billing.gui.component.ValidateJTextField;
import sg.edu.nus.iss.billing.localization.MessageKeyManager;
import sg.edu.nus.iss.billing.validation.ValidationRule;

public class ViewCustomerAddressPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	String[] labelContent = {MessageKeyManager.getMessage("label.address1"), MessageKeyManager.getMessage("label.address2"), MessageKeyManager.getMessage("label.unit"), MessageKeyManager.getMessage("label.postal"),MessageKeyManager.getMessage("label.country")};
	
	private JLabel lblCustHeader;
	private JLabel lblAdd1;
	private JLabel lblAdd2;
	private JLabel lblUnit;
	private JLabel lblPostal;
	private JLabel lblCountry;
	
	private JLabel lblShowCustAdd1;
	private JLabel lblShowCustAdd2;
	private JLabel lblShowCustUnit;
	private JLabel lblShowCustPostal;
	
	private Customer customer;
		
	private int labelHeight = 20;
	private int labelWidth = 200;
	private int fieldControlX = 150;
	private int lblControlX = 10; 

	public ViewCustomerAddressPanel(Customer customer) {
		// TODO Auto-generated constructor stub
		super();
		init();
		this.customer = customer;
		lblShowCustAdd1.setText(customer.getBillingAddress().getAddressLine1());
		lblShowCustAdd2.setText(customer.getBillingAddress().getAddressLine2());
		lblShowCustUnit.setText(customer.getBillingAddress().getUnitNo());
		String postal = customer.getBillingAddress().getPostalCode();
		lblShowCustPostal.setText(postal);
	}
	private JLabel createLabel(String labelContents, int x, int y){
		
		JLabel labelName = new JLabel(labelContents);
		labelName.setVerticalTextPosition(SwingConstants.BOTTOM);
		labelName.setBounds(x, y, labelWidth, labelHeight);
		add(labelName);
		
		return labelName;		
		
	}	
	private void init() {
		// TODO Auto-generated method stub
		setLayout(null);
		setPreferredSize(new Dimension(400,300));
		setBounds( 400, 0, 400, 300);
		
		lblCustHeader = createLabel("Customer Residential Address:", 10, 5);
						
		int controly = 40;
		
		for(int i = 0; i < labelContent.length; i++){
			
			switch(i){
			case 0: lblAdd1 = createLabel(labelContent[i], lblControlX, controly);
					lblShowCustAdd1 = createLabel("", fieldControlX, controly);
					break;
			case 1:	lblAdd2 = createLabel(labelContent[i], lblControlX, controly);
					lblShowCustAdd2 = createLabel("", fieldControlX, controly);
					break;
			case 2:	lblUnit = createLabel(labelContent[i], lblControlX, controly);
					lblShowCustUnit = createLabel("", fieldControlX, controly);
					break;
			case 3:	lblPostal = createLabel(labelContent[i], lblControlX, controly);
					lblShowCustPostal = createLabel("", fieldControlX, controly);
					break;
			case 4: lblCountry = createLabel(labelContent[i], lblControlX, controly);
					createLabel("Singapore", fieldControlX, controly);
					break;
			default:break;
			}//End of Switch
			
			controly = controly + 35;
		}
					
	}	

}
